package org.jetbrains.skiko.sample

import org.jetbrains.skiko.ClipboardManager
import org.jetbrains.skiko.SkiaLayer
import kotlin.experimental.ExperimentalNativeApi
import org.jetbrains.skia.impl.NativePointer
import org.jetbrains.skia.*
import kotlinx.cinterop.*

import platform.ohos.napi_env
import platform.ohos.napi_value

val NodeDrawCallback = staticCFunction { context: COpaquePointer, canvas: COpaquePointer ->
    Canvas.drawCallback(canvas)
}

@ExperimentalNativeApi
@CName("createRootRenderNode")
fun createRootRenderNode(): napi_value {
    val context: NativePtr? = nativeNullPtr
    val node = Canvas.createRootRenderNode(context, NodeDrawCallback)
    return node
}

@ExperimentalNativeApi
@CName("setNodeConstructor")
fun setNodeConstructor(env: napi_env, func: napi_value) {
    Canvas.setNodeConstructor(env, func)
    return
}

@ExperimentalNativeApi
@CName("renderNodeDraw")
fun renderNodeDraw(env: napi_env, jsCanvas: napi_value, jsNode: napi_value) {
    Canvas.renderNodeDraw(env, jsCanvas, jsNode)
    return
}

@ExperimentalNativeApi
@CName("renderNodeNotifyRedraw")
fun renderNodeNotifyRedraw(env: napi_env, jsNode: napi_value) {
    Canvas.renderNodeNotifyRedraw(env, jsNode)
    return
}

@ExperimentalNativeApi
@CName("setPixelRatio")
fun setPixelRatio(ratio: Double) {
    Canvas.setPixelRatio(ratio)
    return
}

@ExperimentalNativeApi
@CName("buildInstance")
fun buildInstance(env: napi_env, func: napi_value) {
    Canvas.buildInstance(env, func)
    return
}